package cn.coldleaf.wiki.services.impl;

import cn.coldleaf.wiki.configure.AppConfig;
import cn.coldleaf.wiki.services.AppInitService;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Service;

import java.io.File;

/**
 * @datetime 2023/10/17 下午3:19
 * @user cold
 **/
@Service
@AllArgsConstructor
public class AppInitServiceImpl implements AppInitService, InitializingBean {
    private final AppConfig config;

    private void initHome(){
        File file = new File(config.getHomeDir());
        if (!file.exists()){
            file.mkdirs();
        }
    }
    @Override
    public void afterPropertiesSet() throws Exception {
        // 初始化应用home文件夹
        initHome();
    }
}
